﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;


namespace TouShuShenQi.BlazorCore.Crawler
{
    public interface ICrawler
    {
        /// <summary>
        /// 爬虫启动事件
        /// </summary>
        event EventHandler<OnStartEventArgs> OnStart;
        /// <summary>
        /// 爬虫完成事件
        /// </summary>
        event EventHandler<OnCompletedEventArgs> OnCompleted;
        /// <summary>
        /// 爬虫出错事件
        /// </summary>
        event EventHandler<OnErrorEventArgs> OnError;


        /// <summary>
        /// 定义Cookie容器
        /// </summary>
        CookieContainer CookiesContainer { get; set; }

        /// <summary>
        /// 爬行地址
        /// </summary>
        Uri CrawlerUrl { get; set; }

        /// <summary>
        /// 超时时间（毫秒）
        /// </summary>
        int Timeout { get; set; }

        /// <summary>
        /// 代理地址127.0.0.1:1080
        /// </summary>
        string ProxyAddress { get; set; }

        /// <summary>
        /// 蜘蛛的请求方式
        /// </summary>
        string Method { get; set; }
        /// <summary>
        /// 用户请求模拟
        /// </summary>
        string UserAgent { get; set; }

        /// <summary>
        /// 异步开始爬行
        /// </summary>
        /// <returns></returns>
        Task<string> StartAsync();
        /// <summary>
        /// 开始爬行
        /// </summary>
        /// <returns></returns>
        string Start();
    }
}
